<?php

class CompanyController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        $view = $this->view;
        
        $articleId = $this->_request->getParam('articleid', 0);
        $post = new Business_Post();
        //获取简短联系方式
        $shortContact = $post->getByCateId(1);
        if (isset($shortContact[0]) && isset($shortContact[0]['content'])) {
        	$view->shortContact = $shortContact[0]['content'];
        } else {
        	$view->shortContact = '';
        }
        
        //获取脚注信息
        $footInfo = $post->getByCateId(3);
        if (isset($footInfo[0]) && isset($footInfo[0]['content'])) {
        	$view->footInfo = $footInfo[0]['content'];
        } else {
        	$view->footInfo = '';
        }
        
        //获取公司简介文章
        $articles = $post->getByCateId(5);
        $view->articles = $articles;
        
        $view->content = '';
        $view->atcTitle = '';
        if (!empty($articles)) {
            if ($articleId == 0) {
                //如果没有指定文章ID就取第一条
                if (isset($articles[0]) && isset($articles[0]['content'])) {
                    $view->atcTitle = $articles[0]['title'];
                	$view->content = $articles[0]['content'];
                }
            } else {
                //遍历找到对应id的文章
            	foreach ($articles as $article) {
            		if ($article['id'] == $articleId) {
            		    $view->atcTitle = $article['title'];
            			$view->content = $article['content'];
            			break;
            		}
            	}
            }
        }
    }
}

